#!/usr/bin/env python
import numpy as np

from .trajectory import Trajectory


class master_trajectory_save(object, Trajectory):
    def __init__(self, delta):
        Trajectory.__init__(self)
        file = open("/home/st/ubuntu_data/test_data/test5_ws/src/mecanum_robot_simulation/trajectory_tracking/data/master_cut2.txt", "r")
        self.tra_list = file.readlines()
        self.tra_length = len(self.tra_list)
        self.delta = delta
   
    def get_position_at(self, t):
        super(master_trajectory_save, self).get_position_at(t)
        index = int(t / self.delta) % self.tra_length
        self.position.x = np.array(self.tra_list[index].strip().split(' '), dtype = np.float32  )[0]
        self.position.y = np.array(self.tra_list[index].strip().split(' '), dtype = np.float32  )[1]

        return self.position

    def get_name(self):
        return str(master_trajectory_save.__name__).replace('Trajectory', '').lower()
